package com.sample.plove.authener.server;

import com.sample.plove.authener.model.BasicAuthParam;
import com.sample.plove.authener.model.ResultState;
import com.sample.plove.authener.model.response.AccessToken;
import com.sample.plove.authener.model.response.AuthAccessToken;
import com.sample.plove.authener.model.response.AuthUserInfo;
import org.springframework.stereotype.Repository;

/**
 * PackageName:com.sample.plover.server.impl
 * Author:Administrator
 * Time:0:37
 * Date:2019/5/14
 * Describe:
 */
@Repository
public interface WechatAuthService {

    /**
     * 获取授权凭证token
     *
     * @return json格式的字符串
     */
    AccessToken getAccessToken();

    /**
     * 获取授权请求url
     *
     * @param basic
     * @param url
     * @return
     * @throws Exception
     */
    String getAuthUrl(BasicAuthParam basic, String url);

    /**
     * 获取网页授权凭证
     *
     * @param basic
     * @param url
     * @return
     */
    AuthAccessToken getAuthAccessToken(BasicAuthParam basic, String url);

    /**
     * 刷新网页授权验证
     *
     * @param basic 参数
     * @param url   请求路径
     * @return 新的网页授权验证
     */
    AuthAccessToken refreshAuthAccessToken(BasicAuthParam basic, String url);

    /**
     * 通过网页授权获取用户信息
     *
     * @param accessToken 网页授权接口调用凭证
     * @param openid      用户唯一标识
     * @return 用户信息
     */
    AuthUserInfo getAuthUserInfo(String accessToken, String openid);

    /**
     * 检验授权凭证（access_token）是否有效
     *
     * @param accessToken 网页授权接口调用凭证
     * @param openid      用户唯一标识
     * @return { "errcode":0,"errmsg":"ok"}表示成功 { "errcode":40003,"errmsg":"invalid
     * openid"}失败
     */
    ResultState authToken(String accessToken, String openid);

}
